
package com.hlkj.pay.app.merchant.ext.impl.alipay;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Repository;

import com.alipay.api.AlipayClient;
import com.alipay.api.domain.*;
import com.alipay.api.request.AlipayOpenAgentConfirmRequest;
import com.alipay.api.request.AlipayOpenAgentCreateRequest;
import com.alipay.api.request.AlipayOpenAgentFacetofaceSignRequest;
import com.alipay.api.request.AlipayOpenAgentOrderQueryRequest;
import com.alipay.api.response.AlipayOpenAgentConfirmResponse;
import com.alipay.api.response.AlipayOpenAgentCreateResponse;
import com.alipay.api.response.AlipayOpenAgentFacetofaceSignResponse;
import com.alipay.api.response.AlipayOpenAgentOrderQueryResponse;
import com.hlkj.framework.common.pojo.CommonResult;
import com.hlkj.framework.common.util.json.JsonUtils;
import com.hlkj.framework.extension.annotation.Extension;
import com.hlkj.pay.app.merchant.ext.ChannelMerchantAccessExtPt;
import com.hlkj.pay.app.merchant.ext.MerchantExtConstant;
import com.hlkj.pay.app.merchant.ext.dto.access.*;
import com.hlkj.pay.app.merchant.ext.impl.alipay.dto.AliPayChannelParams;
import com.hlkj.pay.app.merchant.ext.impl.alipay.dto.AlipayConfig;
import com.hlkj.pay.app.merchant.ext.impl.alipay.handler.AliPayCommonParamsHandle;
import com.hlkj.pay.app.merchant.ext.impl.fuyou.utils.FuYouCallBackParamsParseUtil;
import com.hlkj.pay.dto.merchant.AccessChannelParamsDto;
import com.hlkj.pay.dto.merchant.MerchantAccessDto;
import com.hlkj.pay.dto.merchant.MerchantAccessSignLink;
import com.hlkj.pay.enums.CommonEnum;
import com.hlkj.pay.enums.MerchantEnum;
import com.hlkj.pay.infrastructure.model.merchant.MerchantAccessInfoDO;
import com.hlkj.pay.infrastructure.model.pay.ProviderChannelConfigDO;
import com.hlkj.pay.vo.order.resp.MerchantProductQueryResp;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 支付宝进件操作
 * 
 * @author HlpayTeam
 * @date 2024/09/26 10:25
 */
@Slf4j
@Repository
@RequiredArgsConstructor
@Extension(bizId = MerchantExtConstant.CHANNEL_ALI_PAY)
public class AlipayMerchantAccessExtPt implements ChannelMerchantAccessExtPt {

    private final AliPayCommonParamsHandle aliPayCommonParamsHandle;

    @Override
    public void channelConfigCheck(ChannelMerchantAccessCommonContext channelMerchantAccessCommonContext) {
        CommonResult<AlipayConfig> alipayConfigCommonResult = aliPayCommonParamsHandle.alipayConfig(channelMerchantAccessCommonContext.getProviderChannelConfig(),
                channelMerchantAccessCommonContext.isTest());
        if (!alipayConfigCommonResult.isSuccess()) {
            channelMerchantAccessCommonContext.setRemark(alipayConfigCommonResult.getMsg());
            channelMerchantAccessCommonContext.setProcessStatus(false);
        }
    }

    @Override
    public void merchantAccess(ChannelMerchantAccessContext channelMerchantAccessContext) {
        log.info("支付宝渠道提交进件 请求参数:{}", JsonUtils.toJsonString(channelMerchantAccessContext));
        CommonResult<AlipayConfig> alipayConfigCommonResult = aliPayCommonParamsHandle.alipayConfig(channelMerchantAccessContext.getProviderChannelConfig(),
                channelMerchantAccessContext.isTest());
        if (!alipayConfigCommonResult.isSuccess()) {
            channelMerchantAccessContext.setRemark(alipayConfigCommonResult.getMsg());
            channelMerchantAccessContext.setProcessStatus(false);
            return;
        }
        MerchantAccessDto merchantAccessDto = channelMerchantAccessContext.getMerchantAccessDto();
        MerchantAccessInfoDO merchantAccessInfo = merchantAccessDto.getMerchantAccessInfo();
        // 主体是否企业
        boolean enterprise = MerchantEnum.MERCHANT_TYPE.COMPANY.getCode() == merchantAccessInfo.getType() ? true : false;
        try {
            // 初始化支付宝配置
            AlipayConfig alipayConfig = alipayConfigCommonResult.getData();
            // 获取AlipayClient
            AlipayClient client = aliPayCommonParamsHandle.initClient(alipayConfig);
            // 1.开启代商户签约、创建应用事务
            AlipayOpenAgentCreateModel openAgentCreateModel = new AlipayOpenAgentCreateModel();
            // 支付宝账号
            openAgentCreateModel.setAccount(merchantAccessDto.getMerchantAccessLegal().getOtherValue()) ;
            // 商户联系人信息
            ContactModel contactModel = new ContactModel();
            if(CommonEnum.YES_NO_TYPE.YES.getCode().equals(merchantAccessInfo.getContactType() )){
                contactModel.setContactName(merchantAccessDto.getMerchantAccessLegal().getName());
                contactModel.setContactMobile(merchantAccessDto.getMerchantAccessLegal().getPhone());
            }else{
                contactModel.setContactName(merchantAccessDto.getMerchantAccessContact().getName());
                contactModel.setContactMobile(merchantAccessDto.getMerchantAccessContact().getPhone());
            }
            openAgentCreateModel.setContactInfo(contactModel);

            AlipayOpenAgentCreateRequest openAgentCreateRequest = new AlipayOpenAgentCreateRequest();
            openAgentCreateRequest.setBizModel(openAgentCreateModel);

            log.info("支付宝提交进件 创建事务请求参数:{}", JsonUtils.toJsonString(openAgentCreateRequest));
            AlipayOpenAgentCreateResponse openAgentCreateResp = client.execute(openAgentCreateRequest);
            log.info("支付宝提交进件 创建事务返回参数:{}", JsonUtils.toJsonString(openAgentCreateResp));

            if(!openAgentCreateResp.isSuccess()){
                channelMerchantAccessContext.setRemark(openAgentCreateResp.getSubMsg());
                channelMerchantAccessContext.setProcessStatus(false);
                return;
            }
            // 只有init状态允许进行各种业务接口调用
            if(!openAgentCreateResp.getBatchStatus().equals("init")){
                channelMerchantAccessContext.setRemark("支付宝提交进件 创建事务状态异常,batch_status="+openAgentCreateResp.getBatchStatus());
                channelMerchantAccessContext.setProcessStatus(false);
                return;
            }

            // 2.代签约当面付产品
            AlipayOpenAgentFacetofaceSignRequest openAgentFacetofaceSignRequest = new AlipayOpenAgentFacetofaceSignRequest();
            openAgentFacetofaceSignRequest.setBatchNo(openAgentCreateResp.getBatchNo());
            openAgentFacetofaceSignRequest.setMccCode(merchantAccessDto.getMerchantAccessBusiness().getMcc());
            // 签约并授权
            openAgentFacetofaceSignRequest.setSignAndAuth(true);
            // 费率设置
            openAgentFacetofaceSignRequest.setRate(aliPayCommonParamsHandle.getSettleProductInfo(channelMerchantAccessContext.getMerchantFeeConfigList()));
            // 企业
            if(enterprise){
                openAgentFacetofaceSignRequest.setBusinessLicenseNo(merchantAccessDto.getMerchantAccessLicense().getLicenseCode());
                openAgentFacetofaceSignRequest.setBusinessLicensePic(aliPayCommonParamsHandle.getUploadFileItem(merchantAccessDto.getMerchantAccessLicense().getLicenseUrl()));
                if(merchantAccessDto.getMerchantAccessLicense().getLicenseValidityType() == 1){
                    openAgentFacetofaceSignRequest.setLongTerm(true);
                }
            }else{
                // 营业执照图片。被代创建商户运营主体为个人账户必填，企业账户无需填写
                List<String> fileUrls = merchantAccessDto.getMerchantAccessBusiness().getFileUrls();
                if(CollUtil.isNotEmpty(fileUrls)){
                    openAgentFacetofaceSignRequest.setBusinessLicensePic(aliPayCommonParamsHandle.getUploadFileItem(fileUrls.get(0)));
                }
                openAgentFacetofaceSignRequest.setBusinessLicenseMobile(merchantAccessDto.getMerchantAccessLegal().getPhone());
            }
            openAgentFacetofaceSignRequest.setShopName(merchantAccessDto.getMerchantAccessBusiness().getShortName());
            openAgentFacetofaceSignRequest.setShopScenePic(aliPayCommonParamsHandle.getUploadFileItem(merchantAccessDto.getMerchantAccessBusiness().getStoreIndoorUrl()));
            openAgentFacetofaceSignRequest.setShopSignBoardPic(aliPayCommonParamsHandle.getUploadFileItem(merchantAccessDto.getMerchantAccessBusiness().getStoreHeaderUrl()));
            // 经营地址
            SignAddressInfo signAddressInfo = new SignAddressInfo();
            signAddressInfo.setCountryCode("156");
            signAddressInfo.setProvinceCode(merchantAccessDto.getMerchantAccessBusiness().getProvinceCode());
            signAddressInfo.setCityCode(merchantAccessDto.getMerchantAccessBusiness().getCityCode());
            signAddressInfo.setDistrictCode(merchantAccessDto.getMerchantAccessBusiness().getAreaCode());
            signAddressInfo.setDetailAddress(merchantAccessDto.getMerchantAccessBusiness().getAddress());
            openAgentFacetofaceSignRequest.setShopAddress(signAddressInfo);

            log.info("支付宝提交进件 签约当面付请求参数:{}", JsonUtils.toJsonString(openAgentFacetofaceSignRequest));
            AlipayOpenAgentFacetofaceSignResponse openAgentFacetofaceSignResponse = client.execute(openAgentFacetofaceSignRequest);
            log.info("支付宝提交进件 签约当面付响应参数:{}", JsonUtils.toJsonString(openAgentFacetofaceSignResponse));
            if(!openAgentFacetofaceSignResponse.isSuccess()){
                channelMerchantAccessContext.setProcessStatus(false);
                channelMerchantAccessContext.setRemark(openAgentFacetofaceSignResponse.getSubMsg());
                return;
            }

            // 3.提交代商户开通、创建应用事务
            AlipayOpenAgentConfirmModel confirmModel = new AlipayOpenAgentConfirmModel();
            confirmModel.setBatchNo(openAgentCreateResp.getBatchNo());
            // 请求封装
            AlipayOpenAgentConfirmRequest confirmRequest = new AlipayOpenAgentConfirmRequest();
            confirmRequest.setBizModel(confirmModel);
            log.info("支付宝提交进件 提交事务请求参数:{}", JsonUtils.toJsonString(confirmRequest));
            AlipayOpenAgentConfirmResponse openAgentConfirmResponse = client.execute(confirmRequest);
            log.info("支付宝提交进件 提交事务响应参数:{}", JsonUtils.toJsonString(openAgentConfirmResponse));

            if(openAgentConfirmResponse.isSuccess()){
                // 商户号 用openId
                merchantAccessInfo.setSubMchId(openAgentConfirmResponse.getOrderNo());
                merchantAccessInfo.setApplyNo(openAgentCreateResp.getBatchNo());
                // 下一步就是查询申请状态
                channelMerchantAccessContext.setAccessStatus(MerchantEnum.ACCESS_STATUS.CHANNEL_APPROVE);
                channelMerchantAccessContext.setAuditStatus(MerchantEnum.CHANNEL_CONFIG_STATUS.SUBMIT);
            }else{
                channelMerchantAccessContext.setProcessStatus(false);
                channelMerchantAccessContext.setRemark(openAgentConfirmResponse.getMsg());
                channelMerchantAccessContext.setAccessStatus(MerchantEnum.ACCESS_STATUS.APPROVE_REFUSE);
            }
        }
        catch (Exception e) {
            channelMerchantAccessContext.setProcessStatus(false);
            channelMerchantAccessContext.setRemark(e.getMessage());
            channelMerchantAccessContext.setAccessStatus(MerchantEnum.ACCESS_STATUS.APPROVE_REFUSE);
        }
    }

    @Override
    public String requestUrl(MerchantAccessDto merchantAccessInfoDO) {

        return null;
    }

    @Override
    public String channelParams(AccessChannelParamsDto accessChannelParamsDto) {
        AliPayChannelParams params = JSONUtil.toBean(accessChannelParamsDto.getExtendA(),AliPayChannelParams.class);
        params.setOpenId(accessChannelParamsDto.getSubMchId());
        return JsonUtils.toJsonStringNotNull(params);
    }

    @Override
    public void merchantAccessQuery(ChannelMerchantAccessQueryContext channelMerchantAccessQueryContext) {

        CommonResult<AlipayConfig> alipayConfigCommonResult = aliPayCommonParamsHandle.alipayConfig(channelMerchantAccessQueryContext.getProviderChannelConfig(),
                channelMerchantAccessQueryContext.isTest());
        if (!alipayConfigCommonResult.isSuccess()) {
            channelMerchantAccessQueryContext.setRemark(alipayConfigCommonResult.getMsg());
            channelMerchantAccessQueryContext.setProcessStatus(false);
            return;
        }
        MerchantAccessInfoDO merchantAccessInfo = channelMerchantAccessQueryContext.getMerchantAccessInfo();
        try{
            // 初始化支付宝配置
            AlipayConfig alipayConfig = alipayConfigCommonResult.getData();
            // 获取AlipayClient
            AlipayClient client = aliPayCommonParamsHandle.initClient(alipayConfig);
            AlipayOpenAgentOrderQueryModel openAgentOrderQueryModel = new AlipayOpenAgentOrderQueryModel();
            openAgentOrderQueryModel.setBatchNo(merchantAccessInfo.getApplyNo());
            // 查询申请单状态
            AlipayOpenAgentOrderQueryRequest request = new AlipayOpenAgentOrderQueryRequest();
            request.setBizModel(openAgentOrderQueryModel);

            log.info("支付宝进件查询 请求参数:{}", JsonUtils.toJsonString(request));
            AlipayOpenAgentOrderQueryResponse response = client.execute(request);
            log.info("支付宝进件查询 返回参数:{}", JsonUtils.toJsonString(response));

            if(response.isSuccess()){
                switch (response.getOrderStatus()) {
                    case "MERCHANT_INFO_HOLD":
                    case "MERCHANT_CONFIRM_TIME_OUT":
                    case "MERCHANT_APPLY_ORDER_CANCELED":
                        channelMerchantAccessQueryContext.setProcessStatus(false);
                        channelMerchantAccessQueryContext.setAccessStatus(MerchantEnum.ACCESS_STATUS.APPROVE_REFUSE);
                        channelMerchantAccessQueryContext.setRemark(response.getSubMsg());
                        break;
                    case "MERCHANT_AUDITING":
                        break;
                    case "MERCHANT_CONFIRM":
                        MerchantAccessSignLink merchantAccessSignLink = new MerchantAccessSignLink();
                        merchantAccessSignLink.setLink(response.getConfirmUrl());
                        merchantAccessSignLink.setName("商户确认签约链接");
                        channelMerchantAccessQueryContext.setSignLinks(CollUtil.newArrayList(merchantAccessSignLink));
                        channelMerchantAccessQueryContext.setAccessStatus(MerchantEnum.ACCESS_STATUS.WAIT_SIGNING);
                        break;
                    default:
                        channelMerchantAccessQueryContext.setProcessStatus(false);
                        channelMerchantAccessQueryContext.setRemark(response.getSubMsg());
                        break;
                }

            }else{
                channelMerchantAccessQueryContext.setProcessStatus(false);
                channelMerchantAccessQueryContext.setRemark(response.getMsg());
            }
        }catch (Exception e){
            log.error("支付宝进件查询请求失败,失败信息 message: {}", e);
            channelMerchantAccessQueryContext.setProcessStatus(false);
            channelMerchantAccessQueryContext.setRemark(e.getMessage());
        }

    }

    @Override
    public void merchantSign(ChannelMerchantAccessSignContext channelMerchantAccessSignContext) {
    }

    @Override
    public void merchantSignQuery(ChannelMerchantAccessSignContext channelMerchantAccessSignContext) {
        CommonResult<AlipayConfig> alipayConfigCommonResult = aliPayCommonParamsHandle.alipayConfig(channelMerchantAccessSignContext.getProviderChannelConfig(),
                channelMerchantAccessSignContext.isTest());
        if (!alipayConfigCommonResult.isSuccess()) {
            channelMerchantAccessSignContext.setRemark(alipayConfigCommonResult.getMsg());
            channelMerchantAccessSignContext.setProcessStatus(false);
            return;
        }
        MerchantAccessInfoDO merchantAccessInfo = channelMerchantAccessSignContext.getMerchantAccessInfoDO();
        try{
            // 初始化支付宝配置
            AlipayConfig alipayConfig = alipayConfigCommonResult.getData();
            // 获取AlipayClient
            AlipayClient client = aliPayCommonParamsHandle.initClient(alipayConfig);
            AlipayOpenAgentOrderQueryModel openAgentOrderQueryModel = new AlipayOpenAgentOrderQueryModel();
            openAgentOrderQueryModel.setBatchNo(merchantAccessInfo.getApplyNo());
            // 查询申请单状态
            AlipayOpenAgentOrderQueryRequest request = new AlipayOpenAgentOrderQueryRequest();
            request.setBizModel(openAgentOrderQueryModel);

            log.info("支付宝签约查询 请求参数:{}", JsonUtils.toJsonString(request));
            AlipayOpenAgentOrderQueryResponse response = client.execute(request);
            log.info("支付宝签约查询 返回参数:{}", JsonUtils.toJsonString(response));

            if(response.isSuccess()){
                switch (response.getOrderStatus()) {
                    case "MERCHANT_INFO_HOLD":
                    case "MERCHANT_CONFIRM_TIME_OUT":
                    case "MERCHANT_APPLY_ORDER_CANCELED":
                        channelMerchantAccessSignContext.setProcessStatus(false);
                        channelMerchantAccessSignContext.setAccessStatus(MerchantEnum.ACCESS_STATUS.APPROVE_REFUSE);
                        channelMerchantAccessSignContext.setRemark(response.getSubMsg());
                        break;
                    case "MERCHANT_AUDITING":
                        break;
                    case "MERCHANT_CONFIRM_SUCCESS":
                        channelMerchantAccessSignContext.setAccessStatus(MerchantEnum.ACCESS_STATUS.APPROVE_SUCCESS);
                        channelMerchantAccessSignContext.setAuditStatus(MerchantEnum.CHANNEL_CONFIG_STATUS.FINISH);

                        // // 申请成功之后.提交代商户开通、创建应用事务
                        // AlipayOpenAgentConfirmModel confirmModel = new AlipayOpenAgentConfirmModel();
                        // confirmModel.setBatchNo(merchantAccessInfo.getApplyNo());
                        // // 请求封装
                        // AlipayOpenAgentConfirmRequest confirmRequest = new AlipayOpenAgentConfirmRequest();
                        // confirmRequest.setBizModel(confirmModel);
                        // log.info("支付宝提交进件 提交事务请求参数:{}", JsonUtils.toJsonString(confirmRequest));
                        // AlipayOpenAgentConfirmResponse openAgentConfirmResponse = AliPayApi.doExecute(confirmRequest);
                        // log.info("支付宝提交进件 提交事务响应参数:{}", JsonUtils.toJsonString(openAgentConfirmResponse));
                        //
                        // if(openAgentConfirmResponse.isSuccess()){
                        //     // 更新token
                        //     merchantAccessInfo.setSubMchId(openAgentConfirmResponse.getOpenId());
                        //     AlipayAccessExtentDto alipayAccessExtentDto = new AlipayAccessExtentDto();
                        //     alipayAccessExtentDto.setAppAuthToken(openAgentConfirmResponse.getAppAuthToken());
                        //     alipayAccessExtentDto.setExpiresIn(openAgentConfirmResponse.getExpiresIn());
                        //     alipayAccessExtentDto.setAppRefreshToken(openAgentConfirmResponse.getAppRefreshToken());
                        //     alipayAccessExtentDto.setReExpiresIn(openAgentConfirmResponse.getReExpiresIn());
                        //     merchantAccessInfo.setExtendA(JSONUtil.toJsonStr(alipayAccessExtentDto));
                        // }
                        break;
                    default:
                        channelMerchantAccessSignContext.setProcessStatus(false);
                        channelMerchantAccessSignContext.setRemark(response.getSubMsg());
                        break;
                }
            }else{
                channelMerchantAccessSignContext.setProcessStatus(false);
                channelMerchantAccessSignContext.setRemark(response.getMsg());
            }
        }catch (Exception e){
            log.error("支付宝签约查询请求失败,失败信息 message: {}", e);
            channelMerchantAccessSignContext.setProcessStatus(false);
            channelMerchantAccessSignContext.setRemark(e.getMessage());
        }
    }

    @Override
    public void merchantBusinessOpen(ChannelMerchantBusinessContext channelMerchantBusinessContext) {

    }

    @Override
    public void wechatConfigInit(ChannelMerchantBusinessContext channelMerchantBusinessContext) {
    }

    @Override
    public void wechatConfigAdd(ChannelMerchantBusinessContext channelMerchantBusinessContext) {
    }

    @Override
    public void wechatConfigQuery(ChannelMerchantAccessAuthQueryContext channelMerchantAccessAuthQueryContext) {

    }

    @Override
    public void wechatAuthConfig(ChannelMerchantBusinessContext channelMerchantBusinessContext) {
        // 微信参数配置
    }

    @Override
    public boolean authConfigQueryType() {
        return true;
    }

    @Override
    public void wechatAuthQuery(ChannelMerchantAccessAuthQueryContext channelMerchantAccessAuthQueryContext) {
        // 文件上传完成就是微信参数自动配置
    }

    @Override
    public void alipayAuthConfig(ChannelMerchantBusinessContext channelMerchantBusinessContext) {
    }

    @Override
    public void alipayAuthQuery(ChannelMerchantAccessAuthQueryContext channelMerchantAccessAuthQueryContext) {
    }

    @Override
    public MerchantAccessCallBackDto accessCallBackParamsParse(HttpServletRequest request, ProviderChannelConfigDO providerChannelConfigDO) {
        Map<String, String[]> parameterMap = request.getParameterMap();
        MerchantAccessCallBackDto merchantAccessCallBackDto=new MerchantAccessCallBackDto();
        merchantAccessCallBackDto.setRequestId(parameterMap.get("external_agreement_no")[0]);
        merchantAccessCallBackDto.setSubMchId(parameterMap.get("agreement_no")[0]);
        merchantAccessCallBackDto.setAccessStatus(MerchantEnum.ACCESS_STATUS.WAIT_SET);
        return merchantAccessCallBackDto;
    }

    @Override
    public CommonResult<String> accessCallbackParse(String callBackBody, List<ProviderChannelConfigDO> channelConfigDOList) {
        return null;
    }

    @Override
    public MerchantBusinessCallBackDto businessCallBackParamsParse(String callBackBody, ProviderChannelConfigDO providerChannelConfigDO) {
        return FuYouCallBackParamsParseUtil.businessCallBackParamsParse(callBackBody);
    }

    @Override
    public boolean verify(String callBackBody, ProviderChannelConfigDO providerChannelConfigDO) {
        return true;
    }

    @Override
    public String callBackResponse(CommonResult commonResult) {
        if (commonResult.isSuccess()) {
            return "SUCCESS";
        }
        else {
            return "FAIL";
        }
    }

    @Override
    public void termAdd(ChannelMerchantTermContext channelMerchantTermContext) {

    }

    @Override
    public void reloadMerchantAuth(ChannelMerchantBusinessContext channelMerchantBusinessContext) {

    }

    @Override
    public void channelSplit(ChannelMerchantBusinessContext channelMerchantBusinessContext) {

    }

    @Override
    public void productUpdate(ChannelMerchantBusinessContext channelMerchantBusinessContext) {

    }

    @Override
    public Integer queryMerAuthStatus(ChannelMerchantAccessAuthQueryContext channelMerchantAccessAuthQueryContext) {
        return null;
    }

    @Override
    public MerchantProductQueryResp productQuery(ChannelMerchantBusinessContext channelMerchantBusinessContext) {
        return null;
    }

    @Override
    public MerchantChannelSplitCallBackDto easySplitCallBackParamsParse(HttpServletRequest request, ProviderChannelConfigDO providerChannelConfigDO) {
        return null;
    }

}
